#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int sum=0;
	while(n>=k){
		sum+=n-n%k;
		n=n/k+n%k;
	};
	sum+=n;
	cout<<sum;
	return 0;
}
